package com.m3u8.db.model;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;

@Entity(tableName = "tb_m3u8")
public class M3u8Model implements Parcelable {

    public M3u8Model(String name, String url,
                     String localPath, int state, int tsSize,
                     int hasDownSize, String currentTs, String imagePath,
                     long startTime, long endTime, long time, long hasDownTime, long startDownloadTime,
                     long endDownloadTime) {
        super();
        this.name = name;
        this.url = url;
        this.localPath = localPath;
        this.state = state;
        this.tsSize = tsSize;
        this.hasDownSize = hasDownSize;
        this.currentTs = currentTs;
        this.imagePath = imagePath;
        this.startTime = startTime;
        this.endTime = endTime;
        this.time = time;
        this.hasDownTime = hasDownTime;
        this.startDownloadTime = startDownloadTime;
        this.endDownloadTime = endDownloadTime;
    }

    @Ignore
    public M3u8Model() {
        super();
    }

    @PrimaryKey(autoGenerate = true)
    private long id;

    @ColumnInfo(name = "name")
    private String name;

    @ColumnInfo(name = "url")
    private String url;

    @ColumnInfo(name = "localPath")
    private String localPath;

    @ColumnInfo(name = "state")
    private int state;

    @ColumnInfo(name = "size")
    private int tsSize;

    @ColumnInfo(name = "hasDownSize")
    private int hasDownSize;

    @ColumnInfo(name = "currentTs")
    private String currentTs;

    @ColumnInfo(name = "imagePath")
    private String imagePath;

    @ColumnInfo(name = "startTime")
    private long startTime;//开始时间

    @ColumnInfo(name = "emdTime")
    private long endTime;//结束时间

    @ColumnInfo(name = "time")
    private long time; //总时间

    @ColumnInfo(name = "hasDownTime")
    private long hasDownTime; // 已下载时间

    @ColumnInfo(name = "startDownloadTime")
    private long startDownloadTime;//开始下载时间

    @ColumnInfo(name = "endDownloadTime")
    private long endDownloadTime;//结束下载时间

    @Ignore
    protected M3u8Model(Parcel in) {
        id = in.readLong();
        name = in.readString();
        url = in.readString();
        localPath = in.readString();
        state = in.readInt();
        tsSize = in.readInt();
        hasDownSize = in.readInt();
        currentTs = in.readString();
        imagePath = in.readString();

        startTime = in.readLong();
        endTime = in.readLong();
        time = in.readLong();
        hasDownTime = in.readLong();
        startDownloadTime = in.readLong();
        endDownloadTime = in.readLong();
    }

    public static final Creator<M3u8Model> CREATOR = new Creator<M3u8Model>() {
        @Override
        public M3u8Model createFromParcel(Parcel in) {
            return new M3u8Model(in);
        }

        @Override
        public M3u8Model[] newArray(int size) {
            return new M3u8Model[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(id);
        dest.writeString(name);
        dest.writeString(url);
        dest.writeString(localPath);
        dest.writeInt(state);
        dest.writeInt(tsSize);
        dest.writeInt(hasDownSize);
        dest.writeString(currentTs);
        dest.writeString(imagePath);

        dest.writeLong(startTime);
        dest.writeLong(endTime);
        dest.writeLong(time);
        dest.writeLong(hasDownTime);
        dest.writeLong(startDownloadTime);
        dest.writeLong(endDownloadTime);
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getLocalPath() {
        return localPath;
    }

    public void setLocalPath(String localPath) {
        this.localPath = localPath;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public int getTsSize() {
        return tsSize;
    }

    public void setTsSize(int tsSize) {
        this.tsSize = tsSize;
    }

    public int getHasDownSize() {
        return hasDownSize;
    }

    public void setHasDownSize(int hasDownSize) {
        this.hasDownSize = hasDownSize;
    }

    public String getCurrentTs() {
        return currentTs;
    }

    public void setCurrentTs(String currentTs) {
        this.currentTs = currentTs;
    }

    public String getImagePath() {
        return imagePath;
    }

    public void setImagePath(String imagePath) {
        this.imagePath = imagePath;
    }

    public long getStartTime() {
        return startTime;
    }

    public void setStartTime(long startTime) {
        this.startTime = startTime;
    }

    public long getEndTime() {
        return endTime;
    }

    public void setEndTime(long endTime) {
        this.endTime = endTime;
    }

    public long getStartDownloadTime() {
        return startDownloadTime;
    }

    public void setStartDownloadTime(long startDownloadTime) {
        this.startDownloadTime = startDownloadTime;
    }

    public long getEndDownloadTime() {
        return endDownloadTime;
    }

    public void setEndDownloadTime(long endDownloadTime) {
        this.endDownloadTime = endDownloadTime;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public long getHasDownTime() {
        return hasDownTime;
    }

    public void setHasDownTime(long hasDownTime) {
        this.hasDownTime = hasDownTime;
    }
}
